const createdApp = require('./entry-server.js')
const Vue = require('vue')
const server = require('express')()
const renderer = require('vue-server-renderer').createRenderer({
    template: require('fs').readFileSync('./index.template.html', 'utf-8')
})
server.get('*', (req, res) => {
    const context = { url: req.url }
    createdApp(context).then(app => {
        renderer.renderToString(app).then(html => {
            res.end(html)
        }).catch(err => {
            res.status(500).end('Internal Server Error')
            return
        })
    })
})